{template 'system/common/header'}
<div class="dm-subnav">
    <div class="subnav-title">报表统计</div>
    <ul>
        <li class="{if $operation == 'sale'}active{/if}"><a href="{php echo $this->createWebUrl('statistics', array('op'=>'sale'))}">交易额统计</a></li>
    </ul>
</div>
<div class="dm-container">
<div class="dm-content">
<style type="text/css">
.input-group-select {
    float: right;
}
</style>
<form action="./index.php" method="get" class="form-horizontal table-search">
    <input type="hidden" name="c" value="site" />
    <input type="hidden" name="a" value="entry" />
    <input type="hidden" name="m" value="deam_food" />
    <input type="hidden" name="do" value="statistics" />
    <input type="hidden" name="version_id" value="{php echo intval($_GPC['version_id'])}" />
    <input type="hidden" name="op"  value="sale" />
    <div class="page-toolbar">
    	<div class="input-group">
    		<span class="input-group-select">
				<select name="type" class='form-control' style="width:100px;padding:0 5px;">
	                <option value='0' {if $_GPC['type']==0}selected="selected"{/if}>交易额</option>
	                <option value='1' {if $_GPC['type']==1}selected="selected"{/if}>交易量</option>
	            </select>
    		</span>
    		<span class="input-group-select">
				<select name="day" class='form-control' style="width:100px;padding:0 5px;">
	                <option value=''>日期</option>
	            </select>
    		</span>
    		<span class="input-group-select">
    			<select name="month" class='form-control' style="width:100px;padding:0 5px;">
	                <option value=''>月份</option>
	                {loop $months $m}
	                <option value="{$m['data']}"  {if $m['selected']}selected="selected"{/if}>{$m['data']}月</option>
	                {/loop}
	            </select>
    		</span>
    		<span class="input-group-select">
    			<select name="year" class='form-control' style="width:100px;padding:0 5px;">
	                {loop $years $y}
	                <option value="{$y['data']}"  {if $y['selected']}selected="selected"{/if}>{$y['data']}年</option>
	                {/loop}
	            </select>
    		</span>
    		<span class="input-group-select">
		        <select name="storeid" class="form-control" style="width:250px;padding:0 5px;">
		            <option value="">全部门店</option>
		            {loop $storeList $storeItem}
		            <option value="{$storeItem['id']}" {if $store_id == $storeItem['id']} selected="" {/if}>{$storeItem['name']}</option>
		            {/loop}
		        </select>
		    </span>
    		<span class="input-group-btn">
    			<button class="btn btn-primary" type="submit"> 搜索</button>
    		</span>
    	</div>
	</div>
</form>
<div style="clear: both;margin-bottom: 15px;"></div>
<div class="panel panel-default">
    <div class='panel-heading'>
    {if empty($type)}交易额{else}交易量{/if}：<span style="color:red; ">{$totalcount}</span>，
        最高{if empty($type)}交易额{else}交易量{/if}：<span style="color:red; ">{$maxcount}</span> {if !empty($maxcount_date)}<span>({$maxcount_date}</span>){/if}
    </div>
    <div class="panel-body">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th style='width:150px;'>
                        {if empty($_GPC['month'])}月份{else}日期{/if}
                    </th>
                    <th style='width:200px;'>{if empty($type)}交易额{else}交易量{/if}</th>
                    <th style="width: 80px;">所占比例</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                {loop $list $row}
                <tr>
                    <td>{$row['data']}</td>
                    <td>{$row['count']}</td>
                    <td><span class="process-num" style="color:#000">{php echo empty($row['percent'])?'':$row['percent'].'%'}</span></td>
                    <td>
                       <div class="progress">
                           <div style="width: {$row['percent']}%;" class="progress-bar progress-bar-info" ></div>
                       </div>
                    </td>
                </tr>
                {/loop}
            </tbody>
        </table>
    </div>
</div>
<script language='javascript'>
    function get_days(){
        var year = $('select[name=year]').val();
        var month =$('select[name=month]').val();
        var day  = $('select[name=day]');
       day.get(0).options.length = 0 ;
        if(month==''){
	   day.append("<option value=''>日期</option");
            return;
        }
       
        day.get(0).options.length = 0 ;
        day.append("<option value=''>0</option").attr('disabled',true);
        $.post("{php echo $this->createWebUrl('statistics',array('op'=>'get_day'))}",{year:year,month:month},function(days){
             day.get(0).options.length = 0 ;
             day.removeAttr('disabled');
             days =parseInt(days);
             day.append("<option value=''>日期</option");
             for(var i=1;i<=days;i++){
                 day.append("<option value='" + i +"'>" + i + "日</option");
             }
          
             {if !empty($day)}
                day.val( {$day});
             {/if}
        })
    }
    $('select[name=month]').change(function(){
           get_days();
    })
    
    get_days();
 </script>
</div>
</div>
{template 'system/common/footer'}